﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            
        }
        

        private void label2_Click(object sender, EventArgs e)
        {
            Console.WriteLine();
        }

        private void Lb1_ListIndexChanged(object sender,EventArgs e)
        {
            string ss=tb1.Text.Trim();
            string[] arr = ss.Split();
            ArrayList a1 = new ArrayList();
            int sum = 0;
            foreach (string s in arr)
            {
                a1.Add(int.Parse(s));
                sum += int.Parse(s);
            }
            a1.Sort();
            int len = a1.Count;
            string min = a1[0].ToString(), max = a1[len - 1].ToString();
            int avg = sum / len;

            switch (this.lb1.SelectedIndex)
            {
                case 0: this.l2.Text = max;break;
                case 1:this.l2.Text = min;break;
                case 2:this.l2.Text = avg.ToString();break;
                case 3:this.l2.Text = sum.ToString();break;
                default:break;
            }
        }

    }
}
